package jdk8;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
 * @author xiaoming
 * @version 1.0
 * @date 2018-11-03 17:53
 *  Base64已成为Java类库的标准
 **/
public class Base64Coding {
    public static void main(String[] args) throws UnsupportedEncodingException {
        // ## Basic
        String codingStr = "Hello World";
        // 编码
        String base64EncodedString = Base64.getEncoder().encodeToString(codingStr.getBytes());
        System.out.println("Base64编码: " + base64EncodedString);

        // 解码
        byte[] decodeByte =  Base64.getDecoder().decode(base64EncodedString);
        String s = new String(decodeByte);
        System.out.println("Base64解码: " + new String(decodeByte,"utf-8") );

        // ## URL and Filename safe

        // ## MEMI
    }

}
